#include "serverHead/sys.h"
#include "serverHead/train.h"
// netfd: 交换数据的那个socket的文件描述
// type: 火车信息的类型
// data: 指向火车信息的字符数组指针
// len: 表示火车信息的长度

//从客户端发送数据
int sendTrain(int netFd, train_t* orderTrain){
    ssize_t sret= send(netFd, &orderTrain->order, sizeof(TokenType_), 0);
    sret=send(netFd, &orderTrain->dataLen, sizeof(int), 0);
    sret=send(netFd, orderTrain->data, orderTrain->dataLen, 0);
    return sret; // 执行信息
}

//接收数据
int recvTrain(int netfd, train_t* orderTrain){
    ssize_t sret = recv(netfd, &orderTrain->order, sizeof(TokenType_), 0);
   
    sret=recv(netfd, &orderTrain->dataLen, sizeof(int), 0);
   
    if((orderTrain->order == ORDER_LS) || (orderTrain->order == ORDER_PWD)){
        sret = 0;
        return sret;
    }
    sret = recv(netfd, orderTrain->data, orderTrain->dataLen, 0);

    return sret;
}

